<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="input" placeholder="请输入你的邮箱">

    <script>
        var input = document.getElementById("input");
        input.onkeydown = function(){
            if(event.keyCode == 13&&this.value!=""){
                var value = this.value.trim();
                var reg = /^\w+@[\da-z]+\.com$/g;
                console.log(reg.test(this.value));
            }
        }
    </script>
</body>
</html>